package be.tihh.mgmt.gui.icontreenode;

import javax.swing.*;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.metal.MetalLookAndFeel;
import java.awt.*;
import java.io.Serializable;

// Tree Computer Icon code
public class TreeComputerIcon implements Icon, UIResource, Serializable {
    public void paintIcon(Component c, Graphics g, int x, int y) {
        g.translate(x, y);

        // Fill glass portion of monitor
        g.setColor(MetalLookAndFeel.getPrimaryControl());
        g.fillRect(5, 4, 6, 4);

        // Draw outside edge of monitor
        g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
        g.drawLine(2, 2, 2, 8); // left
        g.drawLine(13, 2, 13, 8); // right
        g.drawLine(3, 1, 12, 1); // top
        g.drawLine(12, 9, 12, 9); // bottom right base
        g.drawLine(3, 9, 3, 9); // bottom left base
        // Draw the edge of the glass
        g.drawLine(4, 4, 4, 7); // left
        g.drawLine(5, 3, 10, 3); // top
        g.drawLine(11, 4, 11, 7); // right
        g.drawLine(5, 8, 10, 8); // bottom
        // Draw the edge of the CPU
        g.drawLine(1, 10, 14, 10); // top
        g.drawLine(14, 10, 14, 14); // right
        g.drawLine(1, 14, 14, 14); // bottom
        g.drawLine(1, 10, 1, 14); // left

        // Draw the disk drives
        g.setColor(MetalLookAndFeel.getControlDarkShadow());
        g.drawLine(6, 12, 8, 12); // left
        g.drawLine(10, 12, 12, 12); // right

        g.translate(-x, -y);
    }

    public int getIconWidth() {
        return 16;
    }

    public int getIconHeight() {
        return 16;
    }
}  // End class TreeComputerIcon
